package com.eci.context.context.lang;

import org.springframework.web.servlet.LocaleResolver;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.Locale;

public class HeaderLocaleResolver  implements LocaleResolver{
	
	private static final String LANG_KEY = "lang";

	@Override
	public Locale resolveLocale(HttpServletRequest request) {
	 
		String lang = request.getHeader(LANG_KEY);
		if(lang == null) {
			return Locale.US;
		}
		
		return new Locale(lang);
	}

	@Override
	public void setLocale(HttpServletRequest request, HttpServletResponse response, Locale locale) {
		 
		
	}

}
